<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<script type="text/javascript">

    // 显示弹窗
    function auditTab(thisId) {
        $('#nurseId').val(thisId);
        $('#nurseModal').modal('show');
    }

    // 保存上级菜单
    function audit(auditStatus) {
        $('#nurseModal').modal('hide');
        $("div[class='modal-backdrop fade in']").remove();
        $.ajax({
            type: 'post',
            url: '<c:url value="/nurse/audit"></c:url>',
            data: {id: $('#nurseId').val(),accountStastus: auditStatus},
            dataType: 'json',
            success: function (data) {
                if(200 == data.code){
                    search();
                    queryStatistics();
                }else{
                    alert(data.message);
                }
            }
        });
    }

</script>
<div class="table-scrollable">

    <table class="table table-striped table-hover table-success" style="text-align:center;">
        <thead>
        <tr>
            <th style="text-align:center;">序号</th>
            <th style="text-align:center;">注册时间</th>
            <th style="text-align:center;">用户名</th>
            <th style="text-align:center;">真实姓名</th>
            <th style="text-align:center;">性别</th>
            <th style="text-align:center;">手机号</th>
            <th style="text-align:center;">科室</th>
            <th style="text-align:center;">当前状态</th>
            <th style="text-align:center;">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${page.result}" var="nurse" varStatus="vs">
            <tr>
                <td>${vs.count + page.offset}</td>
                <%--注册时间--%>
                <td>
                    <fmt:formatDate value="${nurse.createDate}" pattern="yyyy-MM-dd" />
                </td>
                <%--用户名--%>
                <td>${nurse.name}</td>
                <%--真实姓名--%>
                <td>${nurse.userName}</td>
                <%--性别:1、男，0、女，2、保密--%>
                <td>
                    <c:if test="${nurse.sex == 0}">女</c:if>
                    <c:if test="${nurse.sex == 1}">男</c:if>
                    <c:if test="${nurse.sex == 2}">保密</c:if>
                </td>
                <%--手机号--%>
                <td>${nurse.phone}</td>
                <%--科室--%>
                <td>${nurse.departmentName}</td>
                <%--账户状态：1、待审核，2、审核通过，3、审核失败--%>
                <td>
                    <c:if test="${nurse.accountStastus == 1}">待审核</c:if>
                    <c:if test="${nurse.accountStastus == 2}">审核通过</c:if>
                    <c:if test="${nurse.accountStastus == 3}">审核失败</c:if>
                </td>
                <%--操作--%>
                <td>
                    <c:if test="${nurse.accountStastus == 1}">
                        <a href="javascript:;" class="btn btn-sm blue" onclick="auditTab('${nurse.nurseId}')" style="width: 55px;">
                            <i class="fa"></i>审核
                        </a>
                    </c:if>
                    <c:if test="${nurse.accountStastus != 1}">
                        <label style="width: 60px;text-align: center;">-</label>
                    </c:if>
                    <a href="javascript:;" class="btn btn-sm blue" onclick="update('/nurse/nurse?nurseId=${nurse.nurseId}&pageType=departmentNurse')">
                        <i class="fa fa-edit"></i>编辑
                    </a>
                    <a href="javascript:;" class="btn btn-sm red" onclick="show('/nurse/show?id=${nurse.nurseId}&pageType=departmentNurse')">
                        <i class="fa"></i>查看
                    </a>
                    <a href="javascript:;" class="btn btn-sm red" onclick="delStatistics('/nurse/delete?id=${nurse.nurseId}')">
                        <i class="fa fa-trash"></i>删除
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<input type="hidden" name="id" id="nurseId"/>
<div class="modal fade" id="nurseModal" tabindex="-1" role="basic" aria-hidden="true">
    <div style="width: 300px;margin: 300px auto;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title" style="">审核</h4>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn blue" onclick="audit(2)">审核通过</button>
                <button type="button" class="btn blue" onclick="audit(3)">审核失败</button>
                <button type="button" class="btn default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="pageination-panel">${page}</div>
